<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/12 0012
 * Time: 15:11
 */

namespace App\Server;


use App\Exceptions\UploadException;
use Houdunwang\LaravelUpload\Events\UploadEvent;

class UploadServer
{
//上传
public function upload($file,$type){
    $this->check($file,$type);
    $event = new UploadEvent($file);
    event($event);
    ##上传成功的文件y
    return $event->getFile();
}
public function check($file,$type){
    $size=$file->getSize();
    if($size>hd_config('upload.'.$type.'_size')){
        throw new UploadException('文件体积过大');
    }
    $ext=strtolower($file->getClientOriginalExtension());
       if(!in_array($ext,explode(',',hd_config('upload.'.$type.'_type')))){
                throw new UploadException('文件上传不合法');
       }

}
}